// import { setForm, getForm, setImgSrc, getImgSrc, setContent, getContent } from '@/utils/course'

const resetForm = {
  tid: '',
  uid: '',
  type: '',
  number: '',
  name: '',
  sex: '',
  birthday: '',
  headImg: '',
  mobilePhone: '',
  phone: '',
  mail: '',
  wechat: '',
  qq: '',
  idType: '',
  idNo: '',
  province: '',
  city: '',
  address: '',
  signStatus: '',
  title: '',
  coverImg: '',
  seniority: '',
  goodField: '',
  experience: '',
  courseStructure: '',
  teachImg: null,
  teachImgs: [],
  createDate: '',
  lastUpdateDate: '',
  sysUser: { username: null },
  bankCardInfo: {
    bankName: '', // 银行
    cardName: '',
    cardType: '',
    idCard: '', // 身份证号
    name: '',
    phone: ''
  },
  isEdit: false
}
const teacher = {
  state: {
    tRuleForm: {
      tid: '',
      uid: '',
      type: '',
      number: '',
      name: '',
      sex: '',
      birthday: '',
      headImg: '',
      mobilePhone: '',
      phone: '',
      mail: '',
      wechat: '',
      qq: '',
      idType: '',
      idNo: '',
      province: '',
      city: '',
      address: '',
      signStatus: '',
      title: '',
      coverImg: '',
      seniority: '',
      goodField: '',
      experience: '',
      courseStructure: '',
      teachImg: null,
      teachImgs: [],
      createDate: '',
      lastUpdateDate: '',
      sysUser: { username: null },
      bankCardInfo: {
        bankName: '', // 银行
        cardName: '',
        cardType: '',
        idCard: '', // 身份证号
        name: '',
        phone: ''
      },
      isEdit: false
    }, // 表单内容
    tImgSrc: '', // 头像图片路径
    tImgSrc2: '', // 讲师封面图路径
    tContent: '', // 资历背景
    tFileList3: [] // 授课瞬间图片Array
  },

  mutations: {
    T_SET_RULE_FORM: (state, tRuleForm) => {
      state.tRuleForm = tRuleForm
    },
    T_SET_RULE_FORM2: (state, tRuleForm) => {
      const data = Object.assign({}, tRuleForm);
      state.tRuleForm = null;
      state.tRuleForm = data
    },
    T_SET_IMGSRC: (state, imgSrc) => {
      state.tImgSrc = imgSrc
    },
    T_SET_IMGSRC2: (state, imgSrc) => {
      state.tImgSrc2 = imgSrc
    },
    T_SET_CONTENT: (state, content) => {
      state.tContent = content
    },
    SET_FILELIST: (state, content) => {
      state.tFileList3 = content
    },
    SET_ISEDIT: (state, isEdit) => {
      state.tRuleForm.isEdit = isEdit
      // state.phone = phone
    }
  },

  actions: {
    // 表单修改存入store.tRuleForm.isEdit
    tAddlistIsEdit({ commit }, isEdit) {
      return new Promise((resolve) => {
        commit('SET_ISEDIT', isEdit);
        resolve();
      })
    },
    // 表单修改存入store
    tAddlistenForm({ commit }, form) {
      return new Promise((resolve) => {
        commit('T_SET_RULE_FORM', form);
        // tSetForm(form)
        resolve();
      })
    },
    // imgSrc
    tAddlistenImgSrc({ commit }, imgSrc) {
      return new Promise((resolve) => {
        commit('T_SET_IMGSRC', imgSrc);
        // tSetImgSrc(imgSrc)
        resolve();
      })
    },

    // imgSrc2
    tAddlistenImgSrc2({ commit }, imgSrc2) {
      return new Promise((resolve) => {
        commit('T_SET_IMGSRC2', imgSrc2);
        // tSetImgSrc2(content)
        resolve();
      })
    },

    // content
    tAddlistenContent({ commit }, content) {
      return new Promise((resolve) => {
        commit('T_SET_CONTENT', content);
        // tSetContent(content)
        resolve();
      })
    },

    tSetFillist({ commit }, content) {
      return new Promise((resolve) => {
        commit('SET_FILELIST', content);
        resolve();
      })
    },

    tResetFunc({ commit }) {
      return new Promise((resolve) => {
        commit('T_SET_CONTENT', '');
        commit('T_SET_IMGSRC', '');
        commit('T_SET_IMGSRC2', '');
        commit('T_SET_RULE_FORM2', resetForm);
        resolve();
      })
    }
  }
}

export default teacher;
